#ifndef MYAMG_CSRPRECOND_CUH
#define MYAMG_CSRPRECOND_CUH
#include <CSRPrecondKernel.cuh>
#include <Data/CSRMatrixOperator.cuh>

namespace myamg {
    template<typename Integer, typename Real, typename Allocator, typename Derived>
    class CSRPrecond {
    public:
        using matrixType = CSRMatrix<Integer, Real, Allocator>;
        using vectorType = Vector<Real, Allocator>;
        using integerType = Integer;
        using realType = Real;
        using allocatorType = Allocator;

        void setup(const matrixType& A, const bool reuse = false) {
            static_cast<Derived*>(this)->setupImpl(A, reuse);
        }

        void free() {
            static_cast<Derived*>(this)->freeImpl();
        }

        [[nodiscard]] size_t inSize() const {
            return static_cast<const Derived*>(this)->inSizeImpl();
        }

        [[nodiscard]] size_t outSize() const {
            return static_cast<const Derived*>(this)->outSizeImpl();
        }

        void apply(const vectorType& b, vectorType& x) {
            static_cast<Derived*>(this)->applyImpl(b, x);
        }
    };
}

#endif //MYAMG_CSRPRECOND_CUH
